<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <p>msg:{{ msg }}</p>
      <input type="text" v-model="msg" />
      <hr />
      <input
        id="userInput"
        type="text"
        v-bind:value="msg"
        v-on:input="setMsg()"
      />
    </div>
    <script>
      new Vue({
        el: "#app",
        data: {
          msg: "默认值",
        },
        methods: {
          setMsg() {
            let input = document.querySelector("#userInput");
            console.log(input.value);
            this.msg = input.value;
          },
        },
      });
    </script>
  </body>
</html>
